/*
 * ISSOUtils
 * 
 * Feb 24, 2006
 * 
 * Copyright (c) AmSoft Systems, 2006
 */
package net.amsoft.iservice.isso.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;

import net.amsoft.iservice.util.exception.IServiceException;

/**
 * @author rahul
 * 
 */
public class ISSOUtils {
	private static Logger oLogger = Logger.getLogger(ISSOUtils.class);
	
	public static int checkEmailAddress(String sEmailAddress)
			throws IServiceException {
		if (sEmailAddress == null)
			return 0;
		// Set the email pattern string
		String sVerifyingPattern = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\."
				+ "[A-Za-z0-9-]+)*(\\.[_A-Za-z0-9-]+)";
		Pattern p = Pattern.compile(sVerifyingPattern, Pattern.CASE_INSENSITIVE
				| Pattern.UNICODE_CASE | Pattern.MULTILINE);
		// Match the given string with the pattern
		Matcher m = p.matcher(sEmailAddress);
		// check whether match is found
		boolean matchFound = m.matches();
		if (matchFound)
			return 1;
		else
			throw new IServiceException(oLogger,1000);
	}
}
